package demo2;

import javax.xml.crypto.dsig.spec.HMACParameterSpec;
import java.util.Arrays;

/**
 * @Author liangzai
 * @Description:
 */
class MyAarrys<E>{
    public Object[] arr = new Object[10];

    public E getArr(int pos) {
        return (E)arr[pos];
    }

    public void setArr(int pos,E val) {
        arr[pos] = (Object) val;
    }

    public Object[] getArr() {

        return arr;
    }

}

class Alg<E extends Comparable<E>>{
    public E findmax(E[] arr){
        E max = arr[0];
        int n = arr.length;
        for (int i = 1; i < arr.length; i++) {
            if(max.compareTo(arr[i])<0){
                max = arr[i];
            }
        }
        return max;
    }
}

public class Test {
    public static void main(String[] args) {
        Alg<Integer> alg = new Alg();
        Integer[] arr = {1,2,5,2,876,12,68,42,34};
        int max = alg.findmax(arr);
        System.out.println(max);
    }

    public static void main1(String[] args) {
        MyAarrys<Integer> arr = new MyAarrys<>();

        arr.setArr(0,2);
        arr.setArr(1,3);
        arr.setArr(2,4);

        for (int i = 0; i < 3; i++) {
            System.out.println(arr.getArr(i));
        }
    }
}
